package com.jike.noobmoney.mvp.view.widget;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.jike.noobmoney.R;
import com.wang.avi.AVLoadingIndicatorView;


/**
 * Created by xuke on 2017/9/8.
 * <p>正在加载</p>
 */

public class ProgressDialog extends Dialog {

    private LayoutInflater inflater;
    private static View rootView;
    private AVLoadingIndicatorView indicatorView;

   // private GifImageView gifImageView;

    private static ProgressDialog progressDialog = null;

    public ProgressDialog(Context context, int theme) {
        super(context, theme);
        this.inflater = LayoutInflater.from(context);
        initView();
    }

    public void initView() {
        rootView = inflater.inflate(R.layout.layout_progress, null, false);
        //gifImageView = (GifImageView) rootView.findViewById(R.id.gifview_progress_dialog);
        //gifImageView.setImageResource(R.drawable.loading);
        indicatorView = rootView.findViewById(R.id.loading_view);
    }

    public static ProgressDialog createDialog(Activity activity) {
        progressDialog = new ProgressDialog(activity, R.style.ProgressDialog);
        progressDialog.setContentView(rootView);
        progressDialog.setCanceledOnTouchOutside(false);

        WindowManager m = activity.getWindowManager();
        Display d = m.getDefaultDisplay(); // 获取屏幕宽、高
        Window window = progressDialog.getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.height = (int) (d.getHeight());
        params.width = (int) (d.getWidth());
        window.setAttributes(params);

        return progressDialog;
    }

    public void onWindowFocusChanged(boolean hasFocus) {
        if (progressDialog == null) {
            return;
        }
    }

}
